﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace nobrolla
{
	public partial class mainform : Form
	{
		public mainform()
		{
			InitializeComponent();
			fontNormal = textBox1.Font;
			fontBold = new Font(fontNormal, FontStyle.Bold);
		}
		Font fontNormal;
		Font fontBold;

		public Random NewRandom()
		{
			return new Random(DateTime.Now.Millisecond * DateTime.Now.Second);
		}

		/// <summary>
		/// Rolls ballistics for number of models * number of shots, based on BS value meeting cutoff defined by the BS formula
		/// Updates Hits numeric box with number of successes
		/// Checks checkBoxTwinLinked to reroll BS
		/// </summary>
		/// <param name="sender">not used</param>
		/// <param name="e">not used</param>
		private void buttonBS_Click(object sender, EventArgs e)
		{
			Random rand = NewRandom();

			int[] rolls = new int[(int)(numModels.Value * numShots.Value)];

			int goal = BSGoal((int)numBS.Value);
			int shots = (int)(numModels.Value * numShots.Value);
			int hits = 0;

			textBox1.AppendText("Rolling " + numModels.Value + " models x " + numShots.Value + " shots each = " + shots + " shots. BS " + numBS.Value + "\n");
			for (int x = 0; x < shots; x++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				rolls[x] = roll;

				if (roll >= goal)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Blue;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;
					textBox1.SelectionColor = c;
					hits++;
				}
				else
					textBox1.AppendText(roll + " ");
			}
			textBox1.AppendText(" = ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(hits.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" hits (" + (int)(shots*BSOdds((int)numBS.Value)) + "avg)\n");

			if (checkBoxTwinLinked.Checked)
			{
				int tlmisses = shots - hits;
				int newhits = 0;
				textBox1.AppendText("Rerolling " + tlmisses + " misses for twin-linked weapons\n");
				for (int x = 0; x < tlmisses; x++)
				{
					int roll = rand.Next(1, 7);
					if (roll > 6)
						roll = 6;
					rolls[x] = roll;

					if (roll >= goal)
					{
						Color c = textBox1.SelectionColor;
						textBox1.SelectionColor = Color.Blue;
						textBox1.SelectionFont = fontBold;
						textBox1.AppendText(roll + " ");
						textBox1.SelectionFont = fontNormal;
						textBox1.SelectionColor = c;
						newhits++;
					}
					else
						textBox1.AppendText(roll + " ");
				}
				hits += newhits;
				textBox1.AppendText(" = ");
				textBox1.SelectionFont = fontBold;
				textBox1.AppendText(newhits.ToString());
				textBox1.SelectionFont = fontNormal;
				textBox1.AppendText(" more hits, " + hits.ToString() + " total hits\n");
			}

			numHits.Value = hits;
			textBox1.ScrollToCaret();
		}
		private int BSGoal(int AttackerBS)
		{
			return (7 - AttackerBS);
		}
		private double BSOdds(int AttackerBS)
		{
			return (7 - BSGoal(AttackerBS)) / 6.0;
		}

		private void buttonWS_Click(object sender, EventArgs e)
		{
			Random rand = NewRandom();

			int attacks = (int)(numModels.Value * numAttacks.Value);

			int[] rolls = new int[attacks];

			int goal = WSGoal((int)numWS.Value, (int)numEnemyWS.Value);
			int hits = 0;

			textBox1.AppendText("Rolling " + numModels.Value + " models x " + numAttacks.Value + " attacks each = " + attacks + " dice. WS " + numWS.Value + " vs " + numEnemyWS.Value + "\n");
			for (int x = 0; x < attacks; x++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				rolls[x] = roll;

				if (roll >= goal)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Blue;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;

					textBox1.SelectionColor = c;
					hits++;
				}
				else
					textBox1.AppendText(roll + " ");
			}
			textBox1.AppendText(" = ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(hits.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" hits (" + (int)(attacks*WSOdds((int)numWS.Value, (int)numEnemyWS.Value)) + "avg)\n");

			numHits.Value = hits;
			textBox1.ScrollToCaret();
		}
		private int WSGoal(int AttackerWS, int OpponentWS)
		{
			switch (AttackerWS)
			{
				case 1:
					if (OpponentWS >= 3)
						return 5;
					return 4;
				case 2:
					if (OpponentWS <= 1)
						return 3;
					if (OpponentWS >= 5)
						return 5;
					return 4;
				case 3:
					if (OpponentWS <= 2)
						return 3;
					if (OpponentWS >= 7)
						return 5;
					return 4;
				case 4:
					if (OpponentWS <= 3)
						return 3;
					if (OpponentWS >= 9)
						return 5;
					return 4;
				case 5:
					if (OpponentWS <= 4)
						return 3;
					return 4;
				case 6:
					if (OpponentWS <= 5)
						return 3;
					return 4;
				case 7:
					if (OpponentWS <= 6)
						return 3;
					return 4;
				case 8:
					if (OpponentWS <= 7)
						return 3;
					return 4;
				case 9:
					if (OpponentWS <= 8)
						return 3;
					return 4;
				case 10:
					if (OpponentWS <= 9)
						return 3;
					return 4;
				default:
					return 100;
			}
		}
		private double WSOdds(int AttackerWS, int OpponentWS)
		{
			return (7 - WSGoal(AttackerWS, OpponentWS)) / 6.0;
		}

		private void buttonSvT_Click(object sender, EventArgs e)
		{
			Random rand = NewRandom();

			int hits = (int)numHits.Value;

			int[] rolls = new int[hits];

			int goal = STGoal((int)numS.Value, (int)numEnemyT.Value);
			int wounds = 0;

			if (goal > 6)
			{
				numWounds.Value = 0;
				textBox1.AppendText("S" + numS.Value + " vs T" + numEnemyT.Value + " has no effect.\n");
				textBox1.ScrollToCaret();
				return;
			}

			textBox1.AppendText("Rolling " + numHits.Value + " hits. S" + numS.Value + " vs T" + numEnemyT.Value + "\n");
			for (int x = 0; x < numHits.Value; x++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				rolls[x] = roll;

				if (roll >= goal)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Blue;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;

					textBox1.SelectionColor = c;
					wounds++;
				}
				else
					textBox1.AppendText(roll + " ");
			}

			numWounds.Value = wounds;

			textBox1.AppendText(" = ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(wounds.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" wounds (" + (int)(hits*STOdds((int)numS.Value, (int)numEnemyT.Value)) + "avg)\n");
			textBox1.ScrollToCaret();
		}
		private int STGoal(int S, int T)
		{
			switch (S)
			{
				case 1:
					if (T >= 5)
						goto default;
					if (T <= 1)
						return 4;
					if (T == 2)
						return 5;
					return 6;
				case 2:
					if (T >= 6)
						goto default;
					if (T <= 1)
						return 3;
					if (T == 2)
						return 4;
					if (T == 3)
						return 5;
					return 6;
				case 3:
					if (T >= 7)
						goto default;
					if (T <= 1)
						return 2;
					if (T == 2)
						return 3;
					if (T == 3)
						return 4;
					if (T == 4)
						return 5;
					return 6;
				case 4:
					if (T >= 8)
						goto default;
					if (T <= 2)
						return 2;
					if (T == 3)
						return 3;
					if (T == 4)
						return 4;
					if (T == 5)
						return 5;
					return 6;
				case 5:
					if (T >= 9)
						goto default;
					if (T <= 3)
						return 2;
					if (T == 4)
						return 3;
					if (T == 5)
						return 4;
					if (T == 6)
						return 5;
					return 6;
				case 6:
					if (T >= 10)
						goto default;
					if (T <= 4)
						return 2;
					if (T == 5)
						return 3;
					if (T == 6)
						return 4;
					if (T == 7)
						return 5;
					return 6;
				case 7:
					if (T <= 5)
						return 2;
					if (T == 6)
						return 3;
					if (T == 7)
						return 4;
					if (T == 8)
						return 5;
					return 6;
				case 8:
					if (T <= 6)
						return 2;
					if (T == 7)
						return 3;
					if (T == 8)
						return 4;
					if (T == 9)
						return 5;
					return 6;
				case 9:
					if (T <= 7)
						return 2;
					if (T == 8)
						return 3;
					if (T == 9)
						return 4;
					if (T == 10)
						return 5;
					break;
				case 10:
					if (T == 9)
						return 3;
					if (T == 10)
						return 4;
					return 2;
				default:
					return 666;
			}
			return 666;
		}
		private double STOdds(int S, int T)
		{
			return (7 - STGoal(S, T)) / 6.0;
		}

		private void Form1_Load(object sender, EventArgs e)
		{
			textBox1.AppendText("WS v WS chart\n");
			for (int rows = 0; rows <= 10; rows++)
			{
				for (int cols = 0; cols <= 10; cols++)
				{
					if (rows == 0)
					{
						if (cols == 0)
						{
							textBox1.AppendText("     ");
							continue;
						}
						textBox1.AppendText(cols + "   ");
						continue;
					}
					if (cols == 0)
					{
						if (rows == 10)
							textBox1.AppendText(rows + "|");
						else
							textBox1.AppendText(rows + " | ");
						continue;
					}
					textBox1.AppendText(WSGoal(rows, cols) + "+ ");
				}
				textBox1.AppendText("\n");
			}

			textBox1.AppendText("S v T chart\n");
			for (int rows = 0; rows <= 10; rows++)
			{
				for (int cols = 0; cols <= 10; cols++)
				{
					if (rows == 0)
					{
						if (cols == 0)
						{
							textBox1.AppendText("     ");
							continue;
						}
						textBox1.AppendText(cols + "   ");
						continue;
					}
					if (cols == 0)
					{
						if (rows == 10)
							textBox1.AppendText(rows + "|");
						else
							textBox1.AppendText(rows + " | ");
						continue;
					}
					if (STGoal(rows, cols) > 6)
						textBox1.AppendText(" -   ");
					else
						textBox1.AppendText(STGoal(rows, cols) + "+ ");
				}
				textBox1.AppendText("\n");
			}

			int rolls = 60000;
			textBox1.AppendText("Testing random roll generator with "+rolls+" rolls:\n1\t2\t3\t4\t5\t6\n");
			int[] test = new int[] { 0, 0, 0, 0, 0, 0 };
			Random rand = new Random(DateTime.Now.Millisecond * DateTime.Now.Second);
			for (int i = 0; i < rolls; i++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				test[roll-1]++;
			}
			for (int i = 0; i < 6; i++)
				textBox1.AppendText(test[i] + "\t");
			textBox1.AppendText("\n");
			for (int i = 0; i < 6; i++)
				textBox1.AppendText(
					(int)((
						(double)(test[i]) / (double)(rolls)
					)*1000)/10.0
					+ "%\t");
			textBox1.AppendText("\n");
			textBox1.ScrollToCaret();
		}

		private void button1_Click_1(object sender, EventArgs e)
		{
			numBS.Value = 2;
			numShots.Value = 2;
			numAP.Value = 6;

			numWS.Value = 4;

			numAttacks.Value = 3;
			numSShoot.Value = 4;
		}
		private void button3_Click(object sender, EventArgs e)
		{
			numEnemyT.Value = 3;
		}
		private void button4_Click(object sender, EventArgs e)
		{
			numEnemyT.Value = 4;
		}
		private void button5_Click(object sender, EventArgs e)
		{
			numEnemyT.Value = 5;
		}
		private void button8_Click(object sender, EventArgs e)
		{
			numEnemyWS.Value = 3;
		}
		private void button7_Click(object sender, EventArgs e)
		{
			numEnemyWS.Value = 4;
		}
		private void button6_Click(object sender, EventArgs e)
		{
			numEnemyWS.Value = 5;
		}
		private void button9_Click(object sender, EventArgs e)
		{
			numEnemyWS.Value = 6;
		}
		private void button10_Click(object sender, EventArgs e)
		{
			numEnemyT.Value = 6;
		}
		private void button12_Click(object sender, EventArgs e)
		{
			numAP.Value = 6;
			numBS.Value = 2;
			numShots.Value = 1;
			numWS.Value = 4;
			numAttacks.Value = 4;
			numSShoot.Value = 4;
		}
		private void button13_Click(object sender, EventArgs e)
		{
			numWS.Value = 4;

			numAttacks.Value = 2;
			numSShoot.Value = 3;
		}
		private void button14_Click(object sender, EventArgs e)
		{
			numWS.Value = 4;

			numAttacks.Value = 3;
			numSShoot.Value = 4;
		}	
		private void buttonClear_Click(object sender, EventArgs e)
		{
			textBox1.Clear();
		}
		private void buttonShoot_Click(object sender, EventArgs e)
		{
			numS.Value = numSShoot.Value;

			// If enemy is infantry
			if (tabs.SelectedTab == tabinfantry)
			{
				buttonBS_Click(null, null);
				buttonSvT_Click(null, null);

				double avg = (int)numModels.Value * (int)numShots.Value * BSOdds((int)numBS.Value) * STOdds((int)numS.Value, (int)numEnemyT.Value);
				avg = (int)(avg * 10) / 10.0;
				textBox1.AppendText((int)(numModels.Value * numShots.Value) + " shots, " + (int)numHits.Value + " hits, ");
				textBox1.SelectionFont = fontBold;
				textBox1.AppendText((int)numWounds.Value + " wounds");
				textBox1.SelectionFont = fontNormal;
				textBox1.AppendText(" (" + avg + " overall avg");
				if (checkBoxTwinLinked.Checked) textBox1.AppendText(" [not counting TL]");
				textBox1.AppendText(").\n\n");
				textBox1.ScrollToCaret();
				return;
			}

			// If enemy is vehicle
			if (tabs.SelectedTab == tabvehicle)
			{
				buttonBS_Click(null, null);
				buttonVSVehicleS_Click(null, null);

				double penavg = (int)numModels.Value * (int)numShots.Value * BSOdds((int)numBS.Value) * SvAPenOdds((int)numS.Value, (int)numArmorValue.Value);
				penavg = (int)(penavg * 10) / 10.0;
				if (penavg < 0)
					penavg = 0.0;
				double glaavg = (int)numModels.Value * (int)numShots.Value * BSOdds((int)numBS.Value) * SvAGlaOdds((int)numS.Value, (int)numArmorValue.Value);
				glaavg = (int)(glaavg * 10) / 10.0;
				if (glaavg < 0)
					glaavg = 0.0;
				textBox1.AppendText((int)(numModels.Value * numShots.Value) + " shots, " + (int)numHits.Value + " hits, ");
				textBox1.SelectionFont = fontBold;
				textBox1.AppendText((int)numGlances.Value + " glances, " + (int)numPens.Value + " penetrating hits");
				textBox1.SelectionFont = fontNormal;
				textBox1.AppendText(" (" + (glaavg-penavg) + "/" + penavg + " avg).\n\n");
				textBox1.ScrollToCaret();
				return;
			}
		}
		private void textBox1_TextChanged(object sender, EventArgs e)
		{
			textBox1.ScrollToCaret();
		}
		private void buttonAssault_Click(object sender, EventArgs e)
		{
			numS.Value = numSAssault.Value;

			if (tabs.SelectedTab == tabinfantry)
			{
				buttonWS_Click(null, null);
				buttonSvT_Click(null, null);

				double avg = (int)numModels.Value * (int)numAttacks.Value * WSOdds((int)numWS.Value, (int)numEnemyWS.Value) * STOdds((int)numS.Value, (int)numEnemyT.Value);
				avg = (int)(avg * 10) / 10.0;
				textBox1.AppendText((int)(numModels.Value * numAttacks.Value) + " attacks, " + (int)numHits.Value + " hits, ");
				textBox1.SelectionFont = fontBold;
				textBox1.AppendText((int)numWounds.Value + " wounds");
				textBox1.SelectionFont = fontNormal;
				textBox1.AppendText(" (" + avg + " overall avg).\n\n");
				textBox1.ScrollToCaret();
				return;
			}
			if (tabs.SelectedTab == tabvehicle)
			{
				buttonVSVehicleHits_Click(null, null);
				buttonVSVehicleS_Click(null, null);

				double glanceavg = (int)numModels.Value * (int)numAttacks.Value * VehMoveOdds() * SvAGlaOdds((int)numS.Value, (int)numArmorValue.Value);
				double penavg = (int)numModels.Value * (int)numAttacks.Value * VehMoveOdds() * SvAPenOdds((int)numS.Value, (int)numArmorValue.Value);
				glanceavg = (int)(glanceavg * 10) / 10.0;
				penavg = (int)(penavg * 10) / 10.0;
				textBox1.AppendText((int)(numModels.Value * numAttacks.Value) + " attacks, " + (int)numHits.Value + " hits, ");
				textBox1.SelectionFont = fontBold;
				textBox1.AppendText((int)numGlances.Value + " glances, " + (int)numPens.Value + " penetrating hits");
				textBox1.SelectionFont = fontNormal;
				textBox1.AppendText(" (" + glanceavg + "/" + penavg + " avg).\n\n");
				textBox1.ScrollToCaret();
				return;
			}
		}
		private int VehMoveGoal()
		{
			if (radioButton1.Checked)
				return 1;
			if (radioButton2.Checked)
				return 4;
			if (radioButton3.Checked)
				return 6;
			return 100;
		}
		private double VehMoveOdds()
		{
			if (radioButton1.Checked)
				return 1.0;
			if (radioButton2.Checked)
				return 0.5;
			if (radioButton3.Checked)
				return 1.0 / 6.0;
			return 0.0;
		}
		private void buttonVSVehicleHits_Click(object sender, EventArgs e)
		{
			Random rand = NewRandom();

			int attacks = (int)(numModels.Value * numAttacks.Value);

			int[] rolls = new int[attacks];

			int goal = VehMoveGoal();
			int hits = 0;

			if (goal > 6)
			{
				textBox1.AppendText("Select vehicle movement.\n");
				textBox1.ScrollToCaret();
				return;
			}
			if (goal == 1)
			{
				hits = attacks;
				numHits.Value = hits;
				textBox1.AppendText("Vehicle stationary, " + hits + " hits.\n");
				textBox1.ScrollToCaret();
				return;
			}

			textBox1.AppendText("Rolling " + numModels.Value + " models x " + numAttacks.Value + " attacks each = " + attacks + " dice. Need a " + goal + " to hit.\n");
			for (int x = 0; x < attacks; x++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				rolls[x] = roll;

				if (roll >= goal)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Blue;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;

					textBox1.SelectionColor = c;
					hits++;
				}
				else
					textBox1.AppendText(roll + " ");
			}
			textBox1.AppendText(" = ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(hits.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" hits (" + (int)(attacks * VehMoveOdds()) + "avg)\n");

			numHits.Value = hits;
			textBox1.ScrollToCaret();
		}
		private int SvAPenGoal(int s, int a)
		{
			return (a - s + 1);
		}
		private double SvAPenOdds(int s, int a)
		{
			return ((double)(7 - SvAPenGoal(s,a)) / 6.0);
		}
		private int SvAGlaGoal(int s, int a)
		{
			return (a - s);
		}
		private double SvAGlaOdds(int s, int a)
		{
			return ((double)(7 - SvAGlaGoal(s,a)) / 6.0);
		}
		private void buttonVSVehicleS_Click(object sender, EventArgs e)
		{
			Random rand = NewRandom();

			int hits = (int)numHits.Value;

			int[] rolls = new int[hits];

			int goalpen = SvAPenGoal((int)numS.Value, (int)numArmorValue.Value);
			int goalgla = SvAGlaGoal((int)numS.Value, (int)numArmorValue.Value);
			int glancing = 0;
			int penetrating = 0;

			if (goalgla > 6)
			{
				numPens.Value = 0;
				numGlances.Value = 0;
				textBox1.AppendText("S" + numS.Value + " vs Armor " + numArmorValue.Value + " has no effect.\n");
				textBox1.ScrollToCaret();
				return;
			}

			textBox1.AppendText("Rolling " + hits + " hits. S" + numS.Value + " vs Armor " + numArmorValue.Value + "\n");
			for (int x = 0; x < numHits.Value; x++)
			{
				int roll = rand.Next(1, 7);
				if (roll > 6)
					roll = 6;
				rolls[x] = roll;

				if (roll > goalgla)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Blue;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;
					textBox1.SelectionColor = c;
					penetrating++;
				}
				else if (roll == goalgla)
				{
					Color c = textBox1.SelectionColor;
					textBox1.SelectionColor = Color.Teal;
					textBox1.SelectionFont = fontBold;
					textBox1.AppendText(roll + " ");
					textBox1.SelectionFont = fontNormal;
					textBox1.SelectionColor = c;
					glancing++;
				}
				else
					textBox1.AppendText(roll + " ");
			}

			numGlances.Value = (Decimal)glancing;
			numPens.Value = (Decimal)penetrating;

			textBox1.AppendText(" = ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(penetrating.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" penetrating hits (" + (int)(hits * SvAPenOdds((int)numS.Value, (int)numArmorValue.Value)) + "), ");
			textBox1.SelectionFont = fontBold;
			textBox1.AppendText(glancing.ToString());
			textBox1.SelectionFont = fontNormal;
			textBox1.AppendText(" glancing hits (" + (int)(hits * SvAGlaOdds((int)numS.Value, (int)numArmorValue.Value)) + ")\n");
			textBox1.ScrollToCaret();
		}
		private void selectnoweapon()
		{
			numShots.Value = 0;
			numSShoot.Value = 0;
			numAP.Value = 0;
		}
		private void orkboy()
		{
			checkBoxFuriousCharge.Checked = true;

			numWS.Value = 4;
			numAttacks.Value = 2;
			numSAssault.Value = 3;
			if (checkBoxCharging.Checked)
			{
				numAttacks.Value++;
				numSAssault.Value++;
			}

			numBS.Value = 2;

			numShots.Value = 0;
			// slugga, shoota
			numSShoot.Value = 4;
			numAP.Value = 6;
		}
		private void spacemarine()
		{
			checkBoxFuriousCharge.Checked = false;

			numWS.Value = 4;

			numAttacks.Value = 1;
			if (checkBoxCharging.Checked)
				numAttacks.Value++;

			numSAssault.Value = 4;

			numBS.Value = 4;

			// bolter, bolt pistol
			numShots.Value = 1;
			numSShoot.Value = 4;
			numAP.Value = 5;
		}
		private void buttonMarineTac_Click(object sender, EventArgs e)
		{
			spacemarine();
		}
		private void buttonOrkBoyLootas_Click(object sender, EventArgs e)
		{
			orkboy();

			numShots.Value = 0;
			numSShoot.Value = 7;
			numAP.Value = 4;
		}
		private void buttonMarineAssault_Click(object sender, EventArgs e)
		{
			spacemarine();

			numAttacks.Value = 2;
			if (checkBoxCharging.Checked)
				numAttacks.Value++;
		}
		private void buttonOrkBoyShootas_Click(object sender, EventArgs e)
		{
			orkboy();

			numShots.Value = 2;
			numAP.Value = 6;
			numSShoot.Value = 4;
		}
		private void buttonOrkBoySluggas_Click(object sender, EventArgs e)
		{
			orkboy();

			numAttacks.Value = 3;
			if (checkBoxCharging.Checked)
			{
				numAttacks.Value++;
			}

			numShots.Value = 1;
			numAP.Value = 6;
			numSShoot.Value = 4;
		}

		private void quickshoot(int __bs, int __shots, int __s, int __ap)
		{
			// save current info to switch back when done
			decimal tmodels = numModels.Value;
			decimal tbs = numBS.Value;
			decimal tshots = numShots.Value;
			decimal ts = numSShoot.Value;
			decimal tap = numAP.Value;

			numBS.Value = __bs;

			numModels.Value = 1;
			numShots.Value = __shots;

			numSShoot.Value = __s;
			numAP.Value = __ap;

			buttonShoot_Click(null, null);
			textBox1.AppendText("\n");

			// put back to before
			numModels.Value = tmodels;
			numBS.Value = tbs;
			numShots.Value = tshots;
			numSShoot.Value = ts;
			numAP.Value = tap;
		}
		private void buttonBigShoota_Click(object sender, EventArgs e)
		{
			quickshoot(2, 3, 5, 5);
		}
		private void buttonRokkit_Click(object sender, EventArgs e)
		{
			quickshoot(2, 1, 8, 3);
		}
		private void buttonMarineKrak_Click(object sender, EventArgs e)
		{
			quickshoot(4, 1, 8, 3);
		}
		private void buttonMarineMelta_Click(object sender, EventArgs e)
		{
			quickshoot(4, 1, 8, 1);
		}
		private void buttonMarineLas_Click(object sender, EventArgs e)
		{
			quickshoot(4, 1, 9, 2);
		}
		private void buttonMarineHBolter_Click(object sender, EventArgs e)
		{
			quickshoot(4, 3, 5, 4);
		}

		private void orknob()
		{
			checkBoxFuriousCharge.Checked = true;

			if (checkBoxOrkNobWBanner.Checked)
				numWS.Value = 5;
			else
				numWS.Value = 4;

			numAttacks.Value = 3;
			numSAssault.Value = 4;
			if (checkBoxCharging.Checked)
			{
				numAttacks.Value++;
				numSAssault.Value++;
			}

			numBS.Value = 2;

			numShots.Value = 0;
			// slugga, shoota
			numSShoot.Value = 4;
			numAP.Value = 6;
		}
		private void buttonOrkNobChoppa_Click(object sender, EventArgs e)
		{
			orknob();

			// slugga
			numShots.Value = 1;
		}
		private void buttonOrkNobPK_Click(object sender, EventArgs e)
		{
			orknob();

			numSAssault.Value = 8;
			if (checkBoxCharging.Checked)
				numSAssault.Value++;

			// shoota
			numShots.Value = 2;
		}
		private void buttonOrkNobBigChoppa_Click(object sender, EventArgs e)
		{
			orknob();

			numSAssault.Value = 6;
			if (checkBoxCharging.Checked)
				numSAssault.Value++;

			// slugga
			numShots.Value = 1;
		}

		private void checkBoxCharging_CheckedChanged(object sender, EventArgs e)
		{
			if (checkBoxCharging.Checked)
			{
				numAttacks.Value++;
				if (checkBoxFuriousCharge.Checked)
					numSAssault.Value++;
			}
			else
			{
				numAttacks.Value--;
				if (checkBoxFuriousCharge.Checked)
					numSAssault.Value--;
			}
		}

		private void buttonMarineSgtPF_Click(object sender, EventArgs e)
		{
			decimal tmodels = numModels.Value;
			decimal tattacks = numAttacks.Value;
			decimal tstrength = numSAssault.Value;
			decimal tws = numWS.Value;

			numModels.Value = 1;
			numSAssault.Value = 8;
			numAttacks.Value = 2;
			numWS.Value = 4;
			if (checkBoxCharging.Checked)
				numAttacks.Value++;

			buttonAssault_Click(null, null);

			numModels.Value = tmodels;
			numAttacks.Value = tattacks;
			numSAssault.Value = tstrength;
			numWS.Value = tws;
		}

		private void buttonEldarAvengers_Click(object sender, EventArgs e)
		{
			numWS.Value = 4;
			numBS.Value = 4;
			numSAssault.Value = 3;
			numAttacks.Value = 1;

			// shuriken catapault
			numSShoot.Value = 4;
			numAP.Value = 5;
			numShots.Value = 2;
		}
	}
}
